package online.westonline.com.westonline.adapter.im;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.GridView;
import android.widget.RelativeLayout;


import java.util.ArrayList;

import online.westonline.com.westonline.R;
import online.westonline.com.westonline.entry.AppBean;

/**
 * 聊天发送功能选项
 * Created by xiatao on 2018/7/18.
 */

public class MyAppsAdpter extends RelativeLayout
{

    private View view;
    private AppsAdapter adapter;

    /**
     * 获取适配器
     * @return
     */
    public AppsAdapter getAdapter() {
        return adapter;
    }

    public MyAppsAdpter(Context context) {
        super(context);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.view_grid_apps, this);
        init();
    }

    public MyAppsAdpter(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.view_grid_apps, this);
        init();
    }

    private void init() {
        GridView gv_apps = view.findViewById(R.id.gv_apps);
        ArrayList<AppBean> mAppBeanList = new ArrayList<>();
        mAppBeanList.add(new AppBean(R.drawable.ic_insert_photo_grey_500_24dp, "图片"));
        mAppBeanList.add(new AppBean(R.drawable.ic_add_a_photo_grey_500_24dp, "拍照"));
        mAppBeanList.add(new AppBean(R.drawable.ic_video_label_grey_500_24dp, "视频"));
        mAppBeanList.add(new AppBean(R.drawable.ic_insert_drive_file_grey_500_24dp, "文件"));
        mAppBeanList.add(new AppBean(R.drawable.ic_location_on_grey_500_24dp, "位置"));
        adapter = new AppsAdapter(getContext(), mAppBeanList);
        gv_apps.setAdapter(adapter);
    }
}
